package mvn21.model;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

//AspectJ對應切面类
public class MyAspectJ {
	
	//前置通知            连接点--获取目标对象的信息
	public void mybefore(JoinPoint jp) {
		System.out.println("前置通知被调用");
		System.out.println("目标对象："+jp.getTarget());
		System.out.println("目标对象的方法："+jp.getSignature().getName());
	}
	
	//后置通知            连接点--获取目标对象的信息
	public void myAfterReturn(JoinPoint jp,Object objreturn) {
		System.out.println("后置通知被调用");
		System.out.println("目标对象："+jp.getTarget());
		System.out.println("目标对象的方法："+jp.getSignature().getName());
	    System.out.println("返回值为："+objreturn);
	}
	
	//环绕增强
	public Object myAround(ProceedingJoinPoint jp) throws Throwable {
		System.out.println("环绕通知被调用");
		//目标方法被调用
		Object obj = jp.proceed();
		//Object obj = null;
		System.out.println("目标方法被调用");
		return obj;		
	}


}
